<template>
  <div>
    <van-cell-group>

      <van-cell v-for="item in list" :key="item.id" :title="item.vaccineName" :label="'接种人:'+item.vaccinatorName+'接种地点:'+item.hospitalName">
        <template #right-icon>
          <div v-if="item.isState===3">
            <router-link :to="'/back/'+item.id">
              <van-button size="mini" type="danger">不适反馈</van-button>
            </router-link>
          </div>
          <div v-if="item.isState===0||item.isState===-1">
            已取消或过期
            <van-button size="mini" @click="removeById(item.id)">删除记录</van-button>
          </div>
          <div v-if="item.isState===4">
            反馈已提交
          </div>
        </template>
      </van-cell>
    </van-cell-group>

  </div>
</template>

<script>
import appointment from '@/api/appointment'
import Cookies from 'js-cookie'
export default {
  name: 'Finish',
  data() {
    return {
      list: []
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      appointment.ListFinish(Cookies.get('Sysid'))
        .then(response => {
          this.list = response.data.rows
        })
    },
    // 根据id删除数据
    removeById(id) {
      appointment.removeById(id).then((response) => {
        this.fetchData()
        this.$message.success(response.message)
      })
    }
  }
}
</script>

<style scoped>

</style>
